package crudfx.container;
import crudfx.interop.*;
import javax.swing.*;
import javax.swing.border.*;
import crudfx.data.*;
import javafx.scene.paint.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class TabbedPanel extends UIComponent{
    var jTabbedPane:JTabbedPane;
    public var content:Tab[];
    init{
        jTabbedPane=new JTabbedPane();
        for(t:Tab in content){
            t.parent=this;
            jTabbedPane.add(t.text,t.content.getJComponent());
            jTabbedPane.setToolTipTextAt(jTabbedPane.getComponentCount()-1,t.tooltip);
            jTabbedPane.setIconAt(jTabbedPane.getComponentCount()-1,t.icon);
            }
        }
    public function adjustTab(tab:Tab):Void{
        var i:Integer=0;
        for(t:Tab in content){
            if(t==tab){
                jTabbedPane.setTitleAt(i,t.text);
                jTabbedPane.setToolTipTextAt(i,t.tooltip);
                }
            i++;
            };
        }
    override public function getJComponent():JComponent{
        return jTabbedPane;
        }
    override public function highlight(s:String):Boolean{
        for(c:Tab in content){
            if(c.highlight(s))return true;
            }
        return false;
        }
    override public function gather():DataTree{
        var me:DataTree=DataTree{ name:"TabbedPanel" };
        for(c:Tab in content) insert c.gather() into me.node("content").children;
        return me;
        }
    }
